'''
Created on May 02, 2012

@author: samindaw
'''

from net.pycbr.CBR import CBREngine, read_casebase
import os

#load the casebase from the file.
samples_path="resources/samples/"
if (not os.path.isdir("resources")):
    samples_path="../"+samples_path
cb=read_casebase(samples_path+"music.txt")

#instantiate the CBR engine
cbr=CBREngine(cb)

#run the tests

#test 1
data = {"genre":"Metal", "date":"holiday"}
print "Metal songs released on November - "+str(data)
print
results=cbr.search_case(data,10)
for result in results: print str(result[0]["album"].replace("_"," ").replace(","," "))+" ("+str(result[0]["genre"].replace("_"," "))+") - "+str(result[0].get("date",""))+"\t: "+str(result[1])
print
print

#test 2
data = {"genre":"modern,rock", "format":"disc"}
print "Modern Rock Songs easily available on CD's - "+str(data)
print
results=cbr.search_case(data,10)
for result in results: print str(result[0]["album"].replace("_"," ").replace(","," "))+" ("+str(result[0]["genre"].replace("_"," "))+") - "+str(result[0].get("format",""))+"\t: "+str(result[1])
print
print

#test 3
data = {"label":"Warner", "format":"song"}
print "All songs released by warner brothers - "+str(data)
print
results=cbr.search_case(data,10)
for resut in results: print str(result[0]["album"].replace("_"," ").replace(","," "))+" ("+str(result[0]["label"].replace("_"," "))+") "+str(result[0].get("fortmat",""))+"\t: "+str(result[1])
print
print
